﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PBO.Data;

namespace PBO.Game.BattleClass.BattleState
{
    public class PerishSongState : BaseBattleState
    {
        private bool perishSong = false;
        private int perishSongCounter;

        public PerishSongState(Pokemon pokemon) : base(pokemon) { }

        public void OnStateStart()
        {
            this.perishSong = true;
            this.perishSongCounter = 4;
        }

        public override void CountOfEndTurn(BattleGround ground, Action<string> appendText)
        {
            if (this.perishSong && this.pokemon.GetSelTrait() != Trait.Soundproof && this.pokemon.HealthPower > 0)
            {
                this.perishSongCounter--;
                appendText(this.pokemon.GetNameString() + "的灭亡歌倒数:" + this.perishSongCounter);
                if (this.perishSongCounter == 0)
                {
                    this.pokemon.HurtFraction(1);
                    this.perishSong = false;
                }
            }
        }
    }
}
